/**********************************************************************************
 * Copyright (c) 2012 - 2012,  parallel, All right reserved
 * Title: com.adc.parallel.constants  RuntimeList.java 
 * @author shen  shenqiao2012@163.com 
 *  2012-11-21 下午4:12:47 
 *********************************************************************************/


package com.adc.parallel.constants;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;


@SuppressWarnings({"unchecked","rawtypes"})
public class RuntimeList {
	/**
	 * task runtime list,contain completed task,but it will be removed after writen log
	 */
	private static List runtimeList;
	
	/**
	 * @return the runtimeList
	 */
	public synchronized static List getRuntimeList() {
		if (runtimeList==null) {
			runtimeList=Collections.synchronizedList(new ArrayList());
		}
		return runtimeList;
	}

	/**
	 * 
	 * Description: define list type
	 * author:  shen
	 * @return String
	 */
	public static String getType() {
		return SysConstants.ListType_RT;
	}
	
	/**
	 * 
	 * Description: remove taskDto which is completed or failed
	 * author:  shen
	 * @param taskDto
	 * @return boolean
	 */
	public synchronized static boolean removeTaskDto(Object taskDto){
		return runtimeList.remove(taskDto);
	}

	/**
	 * 
	 * Description: to clear persisted dto
	 * author:  shen
	 * @param list 
	 * @return void
	 */
	public static void removeAllDto(final List list) {
		runtimeList.removeAll(list);
	}
}
